/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Administrator
 */
public class TransactForm extends ActionForm {

    private String accNumber;
    private String pass;
    private String transType;
    private int amount;

    /**
     * @return the accNumber
     */
    public String getAccNumber() {
        return accNumber;
    }

    /**
     * @param accNumber the accNumber to set
     */
    public void setAccNumber(String accNumber) {
        this.accNumber = accNumber;
    }

    /**
     * @return the pass
     */
    public String getPass() {
        return pass;
    }

    /**
     * @param pass the pass to set
     */
    public void setPass(String pass) {
        this.pass = pass;
    }

    /**
     * @return the transType
     */
    public String getTransType() {
        return transType;
    }

    /**
     * @param transType the transType to set
     */
    public void setTransType(String transType) {
        this.transType = transType;
    }

    /**
     * @return the amount
     */
    public int getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getAccNumber().length() < 1 || getAccNumber() == null) {
            errors.add("accNo", new ActionMessage("errors.required", "AccountNo"));
        }
        if (getPass().length() < 1 || getPass() == null) {
            errors.add("pass", new ActionMessage("errors.invalid", "Password"));
        }
        if (getTransType() == null) {
            errors.add("repass", new ActionMessage("errors.invalid", "Repass"));
        }
        if (getAmount() < 1) {
            errors.add("balance", new ActionMessage("errors.invalid", "Balance"));
        }
        return errors;
    }
}
